﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Product.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Site.ViewModels.DealIndexModels>" %>

<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Site.ViewModels" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
   Chọn quà theo nhóm, mua quà theo nhóm, mua chung, tặng quà - 
    <%if (Model.ProductType != null)
   {
       Response.Write(Html.Encode(Model.ProductType.Name));
   } %>
    <%if (Model.Category != null)
   {
       Response.Write(" "+Html.Encode(Model.Category.Name));
   } %>
    <%if (Model.ProductHoliday != null)
   {
       Response.Write(" " + Html.Encode(Model.ProductHoliday.Name));
   } %>
   Cùng nhau mua sắm, giảm giá bất ngờ! Giảm giá nhiều mặt hàng từ 30% đến 90% từ muaqua.vn
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MetaContent" runat="server">
    <%var holidays = string.Empty;
      var tyles = string.Empty;
      var cats = string.Empty;
      foreach (var item in Model.ProductHolidays) holidays += item.Name + ", ";
      foreach (var item in Model.ProductTypes) tyles += item.Name + ", ";
      foreach (var item in Model.Categories) cats += item.Name + ", "; %>
    <meta name="page-topic" content='Cùng nhau mua sắm, giảm giá bất ngờ, vui chưa từng có! Giảm giá nhiều mặt hàng từ 30% đến 90% quà tặng, quà sinh nhật, quà cưới, tân gia, gói quà, tặng quà cho <%=tyles %>' />
    <meta name="title" content="<%=holidays %>" />
    <meta name="keywords" content="<%=cats %> - Mua chung, groupon, giam gia, khuyen mai, deal, hàng hot" />
    <meta name="description" content="<%=cats %>- Cùng nhau mua sắm, giảm giá bất ngờ! Giảm giá nhiều mặt hàng từ 30% đến 90%" />
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="PathContent" runat="server">
     <% Html.RenderPartial("~/Views/Deal/Path.ascx", Model); %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="content">
        <%foreach (var item in Model.Products)
           { %>
        <div class="box-sfam mar_r">
            <div class="border-box">
                <div class="pad">
                    <h2>
                        <a href="/deal/details/<%=item.ID %>/<%=Html.ToUrlFriendly(item.Name)%>" class="font_2">
                            <%=Html.Encode(item.Name) %></a></h2>
                    <div class="i_plus">
                        <img src="/images/mq/i_plus.gif" /></div>
                    <div class="des" style="height:47px; overflow:hidden">
                        <%=Html.Encode(item.Summary) %></div>
                    <div class="clear">
                    </div>
                    <div align="center" class="mar_t">
                        <div class="discount_deal">
                            <span>Giảm</span>
                            <div>
                                <%=string.Format("{0:0,0}", item.DiscountPercent) %>%</div>
                        </div>
                        <div class="deadline">
                            <div class="f_l">
                                Còn: <span class="t_note">
                                    <%=SDT.Lib.Common.Utils.GetDaysBetweenDates(DateTime.Now,item.EndDate) %>
                                </span>ngày</div>
                            <%
                                var buyer = item.OrderDetails.Where(e => e.Order.TypeID == SDT.Lib.Common.OrderType.Deal).ToList();
                                var count = buyer.Count > 0 ? buyer.Sum(e => e.Quantity) : 0;
                            %>
                            <div class="f_r">
                                Có: <span class="t_note">
                                    <%=count%></span> phiếu đã bán</div>
                            <div class="clear">
                            </div>
                        </div>
                        <a href="/deal/details/<%=item.ID %>/<%=Html.ToUrlFriendly(item.Name)%>">
                            <% string imgPath = (item.ImagePath != null && item.ImagePath != string.Empty) ? SDT.Lib.Common.Utils.GenThumbnail(item.ID, 286, 190, item.ImagePath, Model.ImagePath, Model.ImageUrl) : SDT.Lib.Common.Globals.DefaultLogo; %>
                            <img src="<%=imgPath %>" title="<%=item.Name %>" alt="<%=item.Name %>" width="286px"
                                height="190px" class="bor-img" />
                        </a>
                    </div>
                    <div class="f_l">
                        <div class="price_off">
                            <%=string.Format("{0:0,0}",item.UnitPrice) %>
                            ₫</div>
                        <div class="price_real">
                            <%=string.Format("{0:0,0}",item.UnitOldPrice) %>
                            ₫</div>
                    </div>
                    <div class="f_r">
                        <%
                          if (item.EndDate.HasValue && item.EndDate.Value>DateTime.Now)
                        {   %>
                        <a href="/deal/create/<%=item.ID %>"><img src="/Images/mq/btn_muangay.gif" /></a>
                        <%}
                      else { %>
                        <a href="/deal/details/<%=item.ID %>/<%=Html.ToUrlFriendly(item.Name)%>"><img src="/Images/mq/btn_muangay.gif" /></a>
                       <%} %>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
            <div>
                <img src="/images/mq/bg_bot.gif" width="340" height="17" /></div>
        </div>
        <%} %>
        <div class="clear">
            &nbsp;</div>
        <div class="pagebarUTH f_r">
            Trang
            <%= Model.Products.PageNumber%>/<%= Model.Products.PageCount%>
            <%= Html.Pager(Model.Products.PageSize, Model.Products.PageNumber, Model.Products.TotalItemCount, new
                {
                    id = Model.CategoryID,
                    typeid = Model.TypeID,
                    holidayid = Model.HolidayID,
                    priceid = Model.PriceID,
                    pageSize = Model.Products.PageSize,                        
                    key = Model.Keyword
                })%>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="RightContent" runat="server">
    <% Html.RenderAction("LastedRightTop", "Banner", new { posid = 5, menuid = 0, number = 0, width = 240, height = 240, order = "Priority", orderDir = "asc" }); %>
    <% Html.RenderPartial("~/Views/Deal/Right.ascx", Model); %>
    <div class="clear">
    </div>
    <div class="mar_t">
        <% Html.RenderAction("LastedRightCenter", "Banner", new { posid = 6, menuid = 0, number = 0, width = 240, height = 240, order = "Priority", orderDir = "asc" }); %>
    </div>
    <div class="mar_t">
        <% Html.RenderAction("LastedRightBottom", "Banner", new { posid = 7, menuid = 0, number = 0, width = 240, height = 240, order = "Priority", orderDir = "asc" }); %>
    </div>
</asp:Content>
